class SessionController < ApplicationController
  def new
    <%= @name %> = <%= class_name %>.new
    render("new.<%= config.language %>")
  end

  def create
    <%= @name %> = <%= class_name %>.find_by(email: params["email"].to_s)
    if <%= @name %> && <%= @name %>.authenticate(params["password"].to_s)
      session[:<%= @name %>_id] = <%= @name %>.id
      flash[:info] = "Successfully logged in"
      redirect_to "/"
    else
      flash[:danger] = "Invalid email or password"
      <%= @name %> = <%= class_name %>.new
      render("new.<%= config.language %>")
    end
  end

  def delete
    session.delete(:<%= @name %>_id)
    flash[:info] = "Logged out. See ya later!"
    redirect_to "/"
  end
end
